﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Summary description for WebhelperMethods
/// </summary>
public static class WebhelperMethods
{
    public static double SecondsSinceUnixTime()
    {
        DateTime unixTime = new DateTime(1970, 1, 1, 0, 0, 0, 0);
        TimeSpan diff = DateTime.Now.ToUniversalTime() - unixTime;
        return Math.Floor(diff.TotalSeconds);
    }

    public static bool SendMail(string emailBody, string subject, string from, string emailto)
    {
        System.Net.Mail.MailMessage mail = new System.Net.Mail.MailMessage();
        System.Net.Mail.SmtpClient SmtpServer = new System.Net.Mail.SmtpClient("mail.pompling.com");
        mail.From = new System.Net.Mail.MailAddress(from);
        mail.To.Add(emailto);
        mail.Subject = subject;
        mail.Body = emailBody;

        SmtpServer.Credentials = new System.Net.NetworkCredential("admin@pompling.co.uk", "Asmtony01");
        SmtpServer.Send(mail);
        return true;
    }
    public static string URLHash(HttpRequest Request)
    {
        if (Request["c"] == null)
            return string.Empty;
        
        string sUrlGUID = Request["c"].ToString();        
        return sUrlGUID;
    }

    public static string GetUrlParamValue(string paramName, HttpRequest Request)
    {
        return Request[paramName];
    }
}